package com.yn.front.zy;

import com.yn.common.page.BasePage;
import com.yn.common.request.sc.PageParamRequest;
import com.yn.common.response.sc.BaseResult;
import com.yn.service.zy.model.dto.TDoctorInfoOutDTO;
import com.yn.service.zy.TDoctorInfoService;
import com.yn.service.zy.model.dto.TDoctorInfoUserDTO;
import com.yn.service.zy.model.query.TDoctorInfoQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/tdoctorinfo")
@Api(tags = "就医绿通")
@Slf4j
public class DoctorInfoController {
    @Autowired
    private TDoctorInfoService tDoctorInfoService;

    /**
     * 列表信息
     */
  /*  @ApiOperation("专家列表")
    @RequestMapping("/list-page")
    public BaseResult listPage(TDoctorInfoQuery query, BasePage basePage){
        IPage<TDoctorInfoOutDTO> doctorInfoDOIPage = tDoctorInfoService.listPageByQuery(query,basePage);

        return BaseResult.success(doctorInfoDOIPage);
    }
*/
    /**
     * 专家列表信息
     * @param query 查询条件
     * @param pageRequest 分页参数
     * @return
     */
    @ApiOperation("专家列表")
    @RequestMapping("/list-page")
    public BaseResult<BasePage<TDoctorInfoOutDTO>> listPage1(TDoctorInfoQuery query, PageParamRequest pageRequest){
        log.info("分页查询专家入参:{}",query);
        return BaseResult.success(tDoctorInfoService.listPageByQuery1(query,pageRequest));
    }


    /**
     * 详情数据
     */
    @ApiOperation("专家详情")
    @GetMapping("/get-info")
    public BaseResult<TDoctorInfoUserDTO> getInfo(@RequestParam(value = "doctorId", required = true)
                                                  @NotNull(message = "请选择专家")
                                                  @ApiParam(value = "专家id", required = true) Integer doctorId) {
        TDoctorInfoOutDTO tDoctorInfoOutDTO = tDoctorInfoService.getInfo(doctorId);


        TDoctorInfoUserDTO tDoctorInfoUserDTO = TDoctorInfoUserDTO.transform(tDoctorInfoOutDTO);
        return BaseResult.success(tDoctorInfoUserDTO);
    }

}
